home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / gamesmaster / demosrc / colourlists.s < prev    next >
Text File  |  1996-07-16  |  5KB  |  175 lines

  1. ;Colour List Example
  2. ;-------------------
  3. ;Colourlists are those nice colour gradients used in demos and games,
  4. ;usually  sitting in the background of your screen.  Colourlists are mostly
  5. ;good for getting more colours on screen than what there really is.
  6. ;Although  the games.library allows you to do other screen effects based on
  7. ;raster lines, we'll just stick to changing colours in this demo.
  8. ;
  9. ;You can move the green colour bar by moving the joystick up and down.
  10. ;You will notice that if you move the green bar into the upper red bar,
  11. ;your bar will disappear.  This is because:
  12. ;
  13. ;    WAITLINE  95        ;Wait for line 95
  14. ;    WAITLINE 100        ;Wait for line 100
  15. ;    WAITLINE  90        ;Wait for line 90 <--Error! 
  16. ;
  17. ;Is not allowed.  The monitor beam travels down the screen, and so the
  18. ;Update_RasterList routine will expect all lines to be in sequential order.
  19. ;Moving two colourbars into each other breaks this rule, causing the wait
  20. ;command to be ignored.  If you want to get around this, you will have to
  21. ;have just one large colourlist and sort your colours before each call to
  22. ;Update_RasterList.
  23. ;
  24. ;Similarly if you move the colour bar too far down the screen the hardware
  25. ;won't like it because lines > 311 don't exist.  It's up to you to be
  26. ;responsible enough to stop this from happening!
  27. ;
  28. ;Press FIRE to exit the demo.
  29.  
  30.     opt    o+
  31.  
  32.     INCLUDE    "exec/exec_lib.i"
  33.     INCLUDE    "games/games_lib.i"
  34.     INCLUDE    "games/games.i
  35.  
  36. LOCAL    =    0
  37.  
  38. CALL    MACRO
  39.     jsr    _LVO\1(a6)
  40.     ENDM
  41.  
  42. ;===========================================================================;
  43. ;                             INITIALISE DEMO
  44. ;===========================================================================;
  45.  
  46.     SECTION    "ColourList",CODE
  47.  
  48. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  49.     move.l    ($4).w,a6
  50.     lea    GMS_Name(pc),a1
  51.     moveq    #$00,d0
  52.     CALL    OpenLibrary
  53.     move.l    d0,GMS_Base
  54.     beq.s    Quit
  55.  
  56.     move.l    GMS_Base(pc),a6
  57.     CALL    SetUserPri
  58.  
  59.     move.l    GMS_Base(pc),a6          ;Tell GMS that we want to add a
  60.     lea    ScreenStruct(pc),a0      ;screen for use.
  61.     CALL    Add_Screen
  62.     tst.l    d0
  63.     bne.s    Error
  64.  
  65.     lea    ScreenStruct(pc),a0      ;Now show the screen/pic.
  66.     CALL    Show_Screen
  67.  
  68. ;===========================================================================;
  69. ;                                MAIN LOOP
  70. ;===========================================================================;
  71.  
  72. Loop:    moveq    #JPORT2,d0               ;Port 2
  73.     moveq    #JT_SWITCH,d1
  74.     CALL    Read_JoyPort
  75.     btst    #JS_FIRE1,d0
  76.     bne.s    .Finished
  77.  
  78. .TUp    btst    #JS_UP,d0
  79.     beq.s    .TDown
  80.     moveq    #-1,d0
  81.     bsr.s    Move_List
  82.     bra.s    .done
  83. .TDown    btst    #JS_DOWN,d0
  84.     beq.s    .done
  85.     moveq    #1,d0
  86.     bsr.s    Move_List
  87.  
  88. .done    CALL    Wait_OSVBL
  89.     bra.s    Loop
  90.  
  91. ;===========================================================================;
  92. ;                              RETURN TO DOS
  93. ;===========================================================================;
  94.  
  95. .Finished
  96.     CALL    Delete_Screen            ;Give back screen memory etc.
  97. Error    move.l    GMS_Base(pc),a1
  98.     move.l    ($4).w,a6
  99.     CALL    CloseLibrary
  100. Quit    MOVEM.L    (SP)+,A0-A6/D1-D7
  101.     moveq    #$00,d0
  102.     rts
  103.  
  104. ;===========================================================================;
  105. ;                             EXTRA ROUTINES
  106. ;===========================================================================;
  107.  
  108. Move_List:
  109.     lea    Bar2(pc),a1
  110.     add.w    d0,2(a1)
  111.     lea    ScreenStruct(pc),a0      ;Update our rasterlist.
  112.     CALL    Update_RasterList
  113.     rts
  114.  
  115. ;===========================================================================;
  116. ;                                  DATA
  117. ;===========================================================================;
  118.  
  119. GMS_Name:
  120.     dc.b    "games.library",0
  121.     even
  122. GMS_Base:
  123.     dc.l    0
  124.  
  125. AMT_PLANES =    5
  126.  
  127. ScreenStruct:
  128.     dc.l    "GSV1"                   ;Structure version.
  129.     dc.l    0,0,0                    ;Screen_Mem1/2/3
  130.     dc.l    0                        ;Screen link.
  131.     dc.l    0                        ;Address of screen palette.
  132.     dc.l    RasterList               ;Address of rasterlist.
  133.     dc.l    0                        ;Amt of colours in palette.
  134.     dc.w    256,320,320/8            ;Screen Height, width, width/8
  135.     dc.w    256,320,320/8            ;Pic Height, width, width/8
  136.     dc.w    AMT_PLANES               ;Amt_Planes
  137.     dc.w    0,0                      ;Top Of Screen: X,Y
  138.     dc.w    0                        ;Scroll buffer size.
  139.     dc.w    0,0                      ;X/Y scroll counters.
  140.     dc.l    NOBURST|BLKBDR           ;Special attributes.
  141.     dc.w    LORES                    ;Screen mode.
  142.     dc.b    INTERLEAVED              ;Screen type
  143.     dc.b    0                        ;Displayed?
  144.     dc.l    0,0                      ;Reserved area.
  145.     even
  146.  
  147. ScreenPalette:
  148.     dc.w    $0000
  149.  
  150. ;===========================================================================;
  151.  
  152. RasterList:
  153.     COL12LIST 000,3,00,ColourBar1    ;Line, Skip, Colnum, ColourList.
  154. Bar2:    COL12LIST 160,1,00,ColourBar2    ;Line, Skip, Colnum, ColourList.
  155.     COL12LIST 230,1,00,ColourBar3    ;Line, Skip, Colnum, ColourList.
  156.     RASTEND
  157.  
  158. ColourBar1:
  159.     dc.w    $100,$200,$300,$400,$500,$600,$700,$800,$900,$a00
  160.     dc.w    $b00,$c00,$d00,$e00,$f00,$e00,$d00,$c00,$b00,$a00
  161.     dc.w    $900,$800,$700,$600,$500,$400,$300,$200,$100,$000
  162.     dc.l    -1
  163.  
  164. ColourBar2:
  165.     dc.w    $010,$020,$030,$040,$050,$060,$070,$080,$090,$0a0
  166.     dc.w    $0b0,$0c0,$0d0,$0e0,$0f0,$0e0,$0d0,$0c0,$0b0,$0a0
  167.     dc.w    $090,$080,$070,$060,$050,$040,$030,$020,$010,$000
  168.     dc.l    -1
  169.  
  170. ColourBar3:
  171.     dc.w    $001,$002,$003,$004,$005,$006,$007,$008,$009,$00a
  172.     dc.w    $00b,$00c,$00d,$00e,$00f,$00e,$00d,$00c,$00b,$00a
  173.     dc.w    $009,$008,$007,$006,$005,$004,$003,$002,$001,$000
  174.     dc.l    -1
  175.